package com.chainshop.sale.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.chainshop.common.core.domain.pojo.Sales;
import com.chainshop.common.utils.poi.ExcelUtil;
import com.chainshop.sale.service.ISaleService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chainshop.common.annotation.Log;
import com.chainshop.common.core.controller.BaseController;
import com.chainshop.common.core.domain.AjaxResult;
import com.chainshop.common.enums.BusinessType;
import com.chainshop.common.core.page.TableDataInfo;

/**
 * @author Yeah
 * @create 2024-08-15-18:45
 * @title
 * @Description:
 */

@RestController
@RequestMapping("/sale/sale")
public class SaleController extends BaseController
{
    @Autowired
    private ISaleService salesService;

    /**
     * 查询存储销售记录的列表
     */
    @PreAuthorize("@ss.hasPermi('sale:sale:list')")
    @GetMapping("/list")
    public TableDataInfo list(Sales sales)
    {
        startPage();
        List<Sales> list = salesService.selectSalesList(sales);
        return getDataTable(list);
    }


    /**
     * 获取存储销售记录的详细信息
     */
    @PreAuthorize("@ss.hasPermi('sale:sale:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Integer orderId)
    {
        return success(salesService.selectSalesByOrderId(orderId));
    }
}
